﻿using LearnDrawing.Controls;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace LearnDrawing.Pages
{
    public class MainViewModel : Screen
    {
        protected override void OnInitialActivate()
        {
            base.OnInitialActivate();
            StartMainTask();
        }

        private readonly Random random = new Random();
        private readonly List<int> DataList = new List<int>();

        public bool Enabled_WithShaps { get; set; }
        public WaveData? WaveData_WithShaps { get; set; }
        public string DrawingTime_WithShaps { get; set; }

        public bool Enabled_WithDrawingVisual { get; set; }
        public WaveData? WaveData_WithDrawingVisual { get; set; }
        public string DrawingTime_WithDrawingVisual { get; set; }

        public bool Enabled_WithDrawingGroup { get; set; }
        public WaveData? WaveData_WithDrawingGroup { get; set; }
        public string DrawingTime_WithDrawingGroup { get; set; }    

        public bool Enabled_WithGDI { get; set; }
        public WaveData? WaveData_WithGDI { get; set; }
        public string DrawingTime_WithGDI { get; set; }

      


        private void StartMainTask()
        {
            for (int i = 0; i < 2000; i++)
            {
                DataList.Add(random.Next(10,360));
            }

            Task.Run(() =>
            {
                while (true)
                {
                    Thread.Sleep(200);

                    DataList.RemoveAt(0);
                    DataList.Add(random.Next(10,360));

                    WaveData waveData = new()
                    {
                        Datas = DataList.ToArray(),
                    };

                    if (Enabled_WithShaps)
                    {
                        WaveData_WithShaps = waveData;
                    }

                    if (Enabled_WithDrawingVisual)
                    {
                        WaveData_WithDrawingVisual = waveData;
                    }

                    if (Enabled_WithDrawingGroup)
                    {
                        WaveData_WithDrawingGroup = waveData;
                    }

                  
                    if (Enabled_WithGDI)
                    {
                        WaveData_WithGDI = waveData;
                    }

                   
                }
            });
        }
    }
}
